import vue from "@vitejs/plugin-vue";
import { resolve } from "node:path";
import { defineConfig, loadEnv } from "vite";

export const r = (...args) => resolve(__dirname, ".", ...args);
// https://vite.dev/config/
export default defineConfig(({ command, mode, isSsrBuild, isPreview }) =>{
  const envConfig = loadEnv(mode, "./");

  return {
    plugins: [
      vue(),
      // esLint({
      //   exclude: ["**/node_modules/**"],
      // }),
    ],
    resolve: {
      alias: {
        "~": `${resolve(__dirname, "./")}`,
        "@/": `${resolve(__dirname, "src")}/`,
      },
    },
    server: {
      port: envConfig.VITE_PORT,
      // proxy: {
      //   '/api': {
      //     target: envConfig.VITE_APP_API_URL,
      //     ws: false,
      //     changeOrigin: true,
      //     rewrite: path => path.replace(/^\/api/, '')
      //   }
      // }
    },
  };
});
